package com.tianya.controller;

import com.tianya.common.Results;
import com.tianya.domain.dto.LoginRequestDTO;
import com.tianya.domain.dto.RegisterDTO;
import com.tianya.domain.vo.LoginVO;
import com.tianya.service.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api("登录相关接口")
@RestController
@RequestMapping("/auth")
public class LoginController {

    @Resource
    private LoginService loginService;

    @ApiOperation("登录接口")
    @PostMapping("/login")
    public Results<LoginVO> login(@RequestBody LoginRequestDTO loginRequestDTO) {
        return Results.success(loginService.login(loginRequestDTO));
    }


    @ApiOperation("注册接口")
    @PostMapping("/register")
    public Results register(@RequestBody RegisterDTO registerDTO) {
        loginService.register(registerDTO);
        return Results.success();
    }
}